package com.magenta.maxoptra.gis;

import static com.magenta.maxoptra.gis.GISFieldType.BOOLEAN;
import static com.magenta.maxoptra.gis.GISFieldType.TEXT;


/**
 * User: KuznetsovD
 * Date: 25.10.11
 * Time: 16:14
 */
public enum CloudmadeMapAttribute implements GISAccountProperty {

    //UseProvider(GisParameter.use_map_provider, MapProviderType.cloudmade, GISFieldType.BOOLEAN, "true", true, 0L, true),
    CloudmadeRoutingUrl(GisParameter.routing_url, MapProviderType.cloudmade, TEXT, "http://routes.cloudmade.com/", true, 1L, true),
    CloudmadeForwardGeocodingUrl(GisParameter.geocoding_url, MapProviderType.cloudmade, TEXT, "http://geocoding.cloudmade.com/%s/geocoding/v2/find.js?", true, 2L, true),
    CloudmadeReverseGeocodingUrl(GisParameter.reverse_geocoding_url, MapProviderType.cloudmade, TEXT, "http://geocoding.cloudmade.com/%s/geocoding/v2/find.js?", true, 3L, true),
    CloudmadeMapKey(GisParameter.map_key, MapProviderType.cloudmade, TEXT, "dd2f72bc0205424bac07bf9483f5735c", true, 1L, true),
    CloudmadeUseShortestRoute(GisParameter.use_shortest_route, MapProviderType.cloudmade, BOOLEAN, "true", true, 5L, true),
    CloudmadeEnableCache(GisParameter.enableCache, MapProviderType.cloudmade, GISFieldType.BOOLEAN, "true", true, 6L, true),
    CloudmadeCacheStorageTime(GisParameter.cacheStorageTime, MapProviderType.cloudmade, GISFieldType.INTEGER, "30", true, 7L, true),
    CloudmadeUseMultiplePointsRouting(GisParameter.useMultiplePointsRouting, MapProviderType.cloudmade, GISFieldType.BOOLEAN, "true", false, 8L, true, true);

    private String name;
    private String label;
    private Long order;
    private GISFieldType type;
    private String defaultValue;
    private boolean required;
    private String groupName;
    private boolean important = true;
    private boolean readOnly = false;
    private String tab = "GIS";

    public boolean isImportant() {
        return important;
    }

    public String getName() {
        return name;
    }

    public GISFieldType getType() {
        return type;
    }

    public String getDefaultValue() {
        return defaultValue;
    }

    public Boolean getMandatory() {
        return required;
    }

    public String getGroup() {
        return groupName;
    }

    public String getLabel() {
        return label;
    }

    public Long getOrder() {
        return order;
    }

    public String getTab() {
        return tab;
    }

    private CloudmadeMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                  boolean required, String groupName, Long order, boolean important, boolean readOnly) {
        this(name, label, type, defaultValue, required, groupName, order, important);
        this.readOnly = readOnly;
    }


    private CloudmadeMapAttribute(String name, String label, GISFieldType type, String defaultValue,
                                  boolean required, String groupName, Long order, boolean important) {
        this.name = name;
        this.label = label;
        this.type = type;
        this.defaultValue = defaultValue;
        this.groupName = groupName;
        this.required = required;
        this.order = order;
        this.important = important;
    }

    private CloudmadeMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                  String defaultValue, boolean required, Long order, boolean important, boolean readOnly) {
        this(parameter, providerType, type, defaultValue, required, order, important);
        this.readOnly = readOnly;
    }


    private CloudmadeMapAttribute(GisParameter parameter, MapProviderType providerType, GISFieldType type,
                                  String defaultValue, boolean required, Long order, boolean important) {
        this(parameter.withProvider(providerType.name()),
                parameter.getLabel(),
                type,
                defaultValue,
                required,
                providerType.getLabel(),
                order, important);
    }

    public boolean isReadOnly() {
        return readOnly;
    }

}
